package cn.yunbamboos.media.exception;

import cn.hutool.core.util.StrUtil;

public class MediaException extends RuntimeException {
    private final int code;

    private final String msg;

    public static MediaException c(String error, Object... arguments) {
        String msg = StrUtil.format(error, arguments);
        return new MediaException(500, msg);
    }

    public static MediaException c(int code, String error, Object... arguments) {
        String msg = StrUtil.format(error, arguments);
        return c(code, msg);
    }

    public static MediaException c(String msg) {
        return c(500, msg);
    }

    public static MediaException c(int code, String msg) {
        return new MediaException(code, msg);
    }

    MediaException(int code, String msg) {
        super(StrUtil.format("code:{} msg:{}", code, msg));
        this.code = code;
        this.msg = msg;
    }

    public int getCode() {
        return this.code;
    }

    public String getMsg() {
        return this.msg;
    }
}